package com.free.semantic.core.common.serializeimpl.baseimpl;

import com.alibaba.fastjson.JSONObject;
import com.free.semantic.common.RelationItem;
import com.free.semantic.core.RelationFunction;
import com.free.semantic.core.common.serializeimpl.BaseSerializeImpl;
import com.free.semantic.core.funcimpl.ConstMapImpl;
import org.springframework.stereotype.Component;

@Component
public class ConstMap implements BaseSerializeImpl {

    private Object value;

    public ConstMap() {
    }

    public ConstMap(ConstMapImpl impl) {
        this.value = impl.getValue();
    }

    @Override
    public JSONObject getParameter() {
        JSONObject parameter = new JSONObject();
        parameter.put("value", value);
        return parameter;
    }

    @Override
    public RelationFunction fromParam(JSONObject parameter) {
        return new ConstMapImpl(parameter.getString("value"));
    }
}
